var uid = getParameter("uid");
var now = new Date();
$(function() {
	charts(now);
});
function charts(now) {
	var urlStr = serverPath + "/app/doctor/diabetes/medicineView.do";
	
	var jsonStr = 
	    '{'+
	    '	   "requestid":"",'+
	    '	   "requestsource":"diabetes",'+
	    '	   "sessionid":"",'+
	    '	   "uid":"'+uid+'",'+
	    '	   "method":"showMedicineChart",'+
	    '	   "version":"1.0",'+
	    '	   "requestlist":'+
	    '	   ['+
	    '	      {'+
	    '			 "befdate":"'+getLastDay(now, 15).format("yyyy-MM-dd")+'",'+
	    '			 "aftdate":"'+getNextDay(now, 15).format("yyyy-MM-dd")+'",'+
	    '			 "day":"30"'+
	    '	      }'+
	    '	   ]'+
	    '	}';
	
	UseAjax(urlStr, jsonStr, document.cookie, rt, '1');
}
function rt(data) {
	var titles = ["服药","未服药"];
	var wi = data.resultlist[0].records;
	var sole =  wi[0];
	var unsole =  wi[1];
	$('#container')
			.highcharts(
					{
						chart : {
							type : 'column'
						},
						title : {
							text :''
							
						},
						subtitle : {
							text :  getLastDay(now, 15).format("yyyy-MM-dd")+" 到 "+getNextDay(now, 15).format("yyyy-MM-dd")
						},
						xAxis : {
							categories : titles
						},
						yAxis : {
							min : 0,
							max : 200,
							tickPixelInterval : 40,
							title : {
								//align: 'high',
				                //offset: 10,
				                text: '次数'
				                //rotation: 0,
				                //y: 20	
				                },
							labels : {
								formatter : function() {
									return "" + this.value ;
								}
							}
						},
						tooltip : {
							headerFormat : '<span style="font-size:10px">{point.key}</span><table>',
							pointFormat : '<tr><td style="color:{series.color};padding:0"> </td>'
									+ '<td style="padding:0"><b>{point.y:.1f} 次</b></td></tr>',
							footerFormat : '</table>',
							shared : true,
							useHTML : true
						},
						plotOptions : {
							column : {
								pointPadding : 0.2,
								borderWidth : 0
							}
						},
						credits : {
							enabled : false
						},
						legend : {
							enabled : false
						},
						series : [ {
							name : null,
							data : [ {
								'color' : "#68ace5",//服药
								'y' : sole
							}, {
								'color' : "#ffc100",//未服药
								'y' : unsole
							}]

						} ]
					});
}
$(function() {
	// swipe 的dome
	$("#container").swipe(
			{
				swipeLeft : function(event, direction, distance, duration,
						fingerCount) {

					now = getNextDay(now, 30);
					charts( now);
				},
				swipeRight : function(event, direction, distance, duration,
						fingerCount) {
					now = getLastDay(now, 30);
					charts( now);
				},
			});

});